import React from "react";
import {Row,Col,Carousel } from "antd";
import "../../../static/css/pc/top.less";
import ImageText from "../components/imagetext";

export default class Top extends React.Component{
	constructor(){
			super();
			this.state={
				topNews:[]
			}
		}
	componentDidMount(){
		var result=fetch("http://www.wwtliu.com/sxtstu/news/juhenews.php?type=top&count=5",{
			method:"get"
		})
		.then(res=>{
			return res.json();
		})
		.then(json=>{
			this.setState({
				topNews:json
			})
		})
	}
	render(){
		var {topNews} = this.state;
		var newsCount = 10;
		return(
			<div>
				<Row>
					<Col span={12}>
						<ul className="topNews">
							{
								topNews.map((item,index) => {
									return <li key={index}><a href={item.url}>{item.title}</a></li>
								})
							}
						</ul>
						<ImageText type="junshi" count={newsCount}></ImageText>
					</Col>
					<Col span={12}>
						<div className="carousel">
							<Carousel>
						    {
						    	topNews.map((item,index) => {
									return <div><img src={item.thumbnail_pic_s} alt="图片"/></div>
								})
						    }
						 </Carousel>
						</div>
					</Col>
				</Row>
			</div>
		)
	}
}